define(['./../initial', './../directive/autoSurveyControlContainer'], function() {
    var app = angular.module('App.home');
    app.factory('AutoSurveyControl', ['$rootScope', '$compile',
        function($rootScope, $compile) {
            var AutoSurveyControl = L.Control.extend({
                options: {
                    position: 'topright'
                },
                onAdd: function(map) {
                    // create the control container with a particular class name
                    var container = document.createElement('div');
                    container.setAttribute('data-auto-survey-control-container', '');
                    var element = angular.element(container);
                    $compile(element)($rootScope);
                    return container;
                },
                onRemove: function(map) {
                    $rootScope.$broadcast('removeAutoSurveyControl');
                }
            });
            return AutoSurveyControl;
        }
    ]);
});
